Repository navigation
Open an LED port that appears after its controller connected (#148) - #153
Merged
Merged
Conversation
…ort, and its LEDs paint into it (#148) devicesChanged only reconnected controllers with no source, so an output port that appeared after its input was never opened. Also binds the one #expect((x?.y ?? []).contains(z)) in the tests to a local: Swift Testing passes that shape when x is nil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCgWWsoPKWUFiYf5pcC5B5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCgWWsoPKWUFiYf5pcC5B5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #148
Summary
devicesChanged() for each controller if it has a source if the source is gone → disconnect + else if it has no LED output → openOutput(…); if opened → repaintLEDs() else if connect(index) → start()Coordinator.connect's output choice now lives inopenOutput(_:for:profile:), so the late-port retry uses exactly the same rules: the chosen port, then the same-name port, then the hint, and never an excluded port.What #148 turned out to be
The issue was filed as "an LED write before the output opens is cached as sent". Testing it at the Coordinator seam found the reachable bug one step earlier: a controller whose output port appears after its input never got that port at all, because
devicesChangedonly reconnected controllers with no source. With the retry in place, every path that opens an output repaints with a cleared cache (start, reconnect, and now a late port). So a write cached while the output was closed is repainted, and no test can observe the cache ordering any more. I left it unchanged rather than add untested code.Found along the way: a test shape that can't fail
#expect((x?.y ?? []).contains(z))passes whenxis nil. Swift Testing expands thecontainscall, and the optional chain short-circuits it. I checked six shapes on a nil subject. Only this one passes;x?.y == v,x?.y ?? [] == vand(x?.y ?? []).last == vall fail correctly.There was exactly one such expectation, in
excludedPortNeverGetsLEDsfrom #144. It's now bound to a local first, and it still passes. The test that first exposed the shape went red properly once its expectation was bound to a local.Evidence
lateOutputPortIsOpened: the controls input is present, with no destination yet, and Playing 1 arrives. Then the controls destination appears,devicesChangedruns, and Playing 1 arrives again. Expect Play at 127 on ch1 on the controls port.Merge Danger
Door: two-way. Blast Radius: device changes.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VCgWWsoPKWUFiYf5pcC5B5